package com.example.demo.controller;

import com.example.demo.domain.Admin;
import com.example.demo.result.RespBean;
import com.example.demo.service.AdminServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/Login")
@CrossOrigin
public class LoginController {
    @Autowired
    AdminServiceImpl adminService;

    @GetMapping("/verify")
    @ResponseBody
    public RespBean VerifyLogin(@RequestParam("user_name") String user_name,
                                @RequestParam("password") String password){
        Admin admin;
        System.out.println(user_name);
        System.out.println(password);
        admin = adminService.verify(user_name,password);
        if(admin != null){
            return RespBean.success("登录成功！",admin);
        }
        return RespBean.error("用户名或密码错误！");
    }
}
